#pragma once
#include "stdafx.h"
#include "Scheduler.h"
#include "Operator.h"
#include "IStreamInput.h"

#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include "IStreamInput.h"
#include "IStreamOutput.h"
#include "JsonSchema.h"
#include "QueryIntermediateRepresentation.h"
#include "CommandManager.h"
#include "IOManager.h"
#include "Types.h"
#include "json.h"
#include "RandomGeneratedStreamInput.h"
#include "JsonStreamServer.h"
#include "SocketStreamInput.h"
#include "SocketStreamOutput.h"
#include "IStreamOutput.h"
#include "IStreamInput.h"
#include "ShowResultStreamOutput.h"
#include "QueryManager.h"
#include "PlanManager.h"
#include "Scheduler.h"
#include "WrapperManager.h"
#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
/* the JSON server engine 
 */

class JsonStreamServer:private boost::noncopyable
{
private:
	
	boost::condition isDataComingCondition;
	bool isDataComing;
	boost::mutex monitorMutex;

	static JsonStreamServer* jsonStreamServer;
	JsonStreamServer(void);
	~JsonStreamServer(void);
	void initial();

public:
	static JsonStreamServer* getInstance(void);
	void execute();

	void registerQuery(boost::shared_ptr<QueryIntermediateRepresentation>intermediateQuery,boost::shared_ptr<IStreamOutput> streamOutput);
	void registerStreamInput(boost::shared_ptr<IStreamInput> streamInput);
};

